class Retangular:
  def __init__(self):
    self.width = 0
    self.height = 0
    self.top = 0
    self.left = 0
  def __setattr__(self, name, value):
    # print("__setattr__ : {}.".format(name))
    if name == 'size':
      self.width, self.height = value
    elif name == 'position':
      self.top, self.left = value
    else:
      # __dict__成员变量, 用来保存对象中所有属性的值, 这句话非常重要, 否则width/height/top/left都无法设置上去
      self.__dict__[name] = value
  def __getattr__(self, name):
    # print("__getattr__ : {}.".format(name))
    if name == 'size':
      return self.width, self.height
    if name == 'position':
      return self.top, self.left
  def __delattr__(self, name):
    # print('__delattr__')
    if name == 'position':
      self.top, self.left = 0, 0
    if name == 'size':
      self.width, self.height = 0, 0


c = Retangular()
c.size = 100, 100
print(c.size)
c.position = 5, 15
print(c.position)
del c.position
print(c.size)
print(c.position)